var t, a = require("../../../../@babel/runtime/helpers/interopRequireDefault"), e = require("../../../../@babel/runtime/helpers/defineProperty"), n = a(require("../../../../utils/util.js")), i = getApp();

Page({
    data: (t = {
        page: 1,
        activeName: "0",
        tabArr: [ "全部", "竞拍中", "即将开始", "已结束" ],
        isLoadMore: !0
    }, e(t, "page", 1), e(t, "last_page", 0), e(t, "current_page", 1), e(t, "styleType", 2), 
    e(t, "auctionColor", "#f5f5f5"), e(t, "auctionImg", ""), e(t, "beginStatus", 0), 
    t),
    onLoad: function(t) {
        this.getdata(), this.getNew();
    },
    onChange: function(t) {
        console.log(t);
        var a = t.detail.index;
        this.setData({
            activeName: a
        }), this.initData(), 0 != a ? this.newListData() : this.getNew();
    },
    initData: function() {
        this.setData({
            loading: !1,
            isLoadMore: !1,
            page: 1,
            total_page: 0,
            datas: [],
            lsitData: []
        });
    },
    tolink: function(t) {
        var a = t.currentTarget.dataset.item.small_url;
        wx.navigateTo({
            url: a
        });
    },
    slideNavTo: function(t) {
        console.log(t);
        var a = t.currentTarget.dataset.url;
        wx.navigateTo({
            url: a
        });
    },
    imgH: function(t) {
        var a = wx.getSystemInfoSync().windowWidth * t.detail.height / t.detail.width + "px";
        this.setData({
            Hei: a
        });
    },
    goMy: function() {
        wx.navigateTo({
            url: "/packageD/auction/auction-mine/my_index/my_index"
        });
    },
    gosearch: function() {
        wx.navigateTo({
            url: "/packageD/auction/auction/auction_search/auction_search"
        });
    },
    toMore: function(t) {
        var a = t.currentTarget.dataset.is_recommend;
        wx.navigateTo({
            url: "/packageD/auction/auction/auction_more/auction_more?is_recommend=" + a
        });
    },
    toMoreNew: function(t) {
        var a = t.currentTarget.dataset.is_new;
        wx.navigateTo({
            url: "/packageD/auction/auction/auction_more/auction_more?is_new=" + a
        });
    },
    toDetail: function(t) {
        var a = t.currentTarget.dataset.id.goods_id, e = t.currentTarget.dataset.id.member_id ? t.currentTarget.dataset.id.member_id : t.currentTarget.dataset.id.auctioneer_id;
        wx.navigateTo({
            url: "/packageD/auction/auction/auction_good/auction_good?id=" + a + "&member_id=" + e
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.getNewMore();
    },
    onShareAppMessage: function() {},
    getNew: function() {
        var t = this, a = i.getNetAddresss("plugin.auction.api.index.getAuctionData"), e = {
            keyword: "",
            status: 1,
            auc_status: "",
            is_new: 1,
            is_recommend: "",
            auctioneer_id: "",
            art: "getSearch",
            page: this.data.page
        };
        i._postNetWork({
            url: a,
            data: e,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    console.log(e);
                    var n = e.data, i = null == n ? void 0 : n.auction_style;
                    t.setData({
                        datas: e.data.getSearch.data,
                        current_page: e.data.getSearch.current_page,
                        last_page: e.data.getSearch.last_page,
                        styleType: i.auction_style,
                        auctionColor: i.auction_style_color,
                        auctionImg: i.auction_style_image
                    });
                } else wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getdata: function() {
        var t = this, a = i.getNetAddresss("plugin.auction.api.index.getAuctionData");
        i._postNetWork({
            url: a,
            data: {
                art: "index"
            },
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    console.log(e);
                    for (var i = e.data, o = 0; o < e.data.index.recommend.length; o++) e.data.index.recommend[o].end_shooting = n.default.formatTimeTwo(e.data.index.recommend[o].end_shooting, "Y-M-D h:m:s");
                    t.setData({
                        rotation: e.data.index.rotation,
                        recommend: e.data.index.recommend,
                        styleType: null == i ? void 0 : i.auction_style.auction_style
                    }), console.log(t.data.styleType);
                } else wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getNewMore: function() {
        var t = this, a = this;
        if (!(this.data.current_page >= this.data.last_page)) {
            var e = a.data.page + 1;
            if (a.setData({
                page: e
            }), 0 == this.data.activeName) {
                var n = i.getNetAddresss("plugin.auction.api.index.getAuctionData"), o = {
                    keyword: "",
                    status: 1,
                    auc_status: "",
                    is_new: 1,
                    is_recommend: "",
                    auctioneer_id: "",
                    art: "getSearch",
                    page: this.data.page
                };
                i._postNetWork({
                    url: n,
                    data: o,
                    success: function(t) {
                        var e = t.data;
                        1 == e.result ? (console.log(e), a.setData({
                            datas: a.data.datas.concat(e.data.getSearch.data),
                            current_page: e.data.getSearch.current_page,
                            last_page: e.data.getSearch.last_page
                        })) : wx.showToast({
                            title: e.msg,
                            icon: "none",
                            duration: 1e3
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            } else {
                var s = i.getNetAddresss("plugin.auction.api.index.index-page"), r = {
                    auction_type: this.data.activeName,
                    page: this.data.page
                };
                i._postNetWork({
                    url: s,
                    data: r,
                    success: function(a) {
                        var e = a.data;
                        1 == e.result ? t.setData({
                            lsitData: t.data.lsitData(e.data.list.data),
                            current_page: e.dta.list.current_page,
                            last_page: e.data.list.last_page
                        }) : wx.showToast({
                            title: e.msg,
                            icon: "none",
                            duration: 1e3
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    }
                });
            }
        }
    },
    newListData: function() {
        var t = this, a = i.getNetAddresss("plugin.auction.api.index.index-page"), e = {
            auction_type: this.data.activeName
        };
        i._postNetWork({
            url: a,
            data: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    lsitData: e.data.list.data,
                    current_page: e.data.list.current_page,
                    last_page: e.data.list.last_page
                }) : wx.showToast({
                    title: e.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});